<?php
/**
 * Model for Form Generator
 * @package cms-generator/models
 * @category Model
 * 
 * @author Mark Angelo Angulo
 * @copyright (c) 2014
 */
class Generator_Model extends Crud {
    
    /*
     *  constructor function
     */
    function __construct()
    {
	parent::__construct();
        $this->table = 'bt_modules';
    }
    
    function retrieve_data($table, $value, $text, $image)
    {
        if($image == 'none')
        {
            if ( $this->db->table_exists($table) && $this->db->field_exists($value, $table) && $this->db->field_exists($text, $table) )
            {
                $this->db->select("$value AS value, $text AS text", FALSE);
                $data = $this->db->get($table);

                return $data->result_array();
            } else
            {
                return FALSE;
            }
        } else
        {
            if ($this->db->table_exists($table) && $this->db->field_exists($value, $table) && $this->db->field_exists($text, $table) && $this->db->field_exists($image, $table) )
            {
                $this->db->select("$value AS value, $text AS text, $image AS image", FALSE);
                $data = $this->db->get($table);

                return $data->result_array();
            } else
            {
                return FALSE;
            }
        }
    }
}

/* End of file generator_model.php */
/* Location: ./application/modules/cms-generator/models/generator_model.php */